package cn.enjoy.design.behavior.strategy.springInitializingBeanPlus.controller;

import cn.enjoy.design.behavior.strategy.springInitializingBeanPlus.GenericInterface;
import cn.enjoy.design.behavior.strategy.springInitializingBeanPlus.HandlerFactory;
import cn.enjoy.design.behavior.strategy.springInitializingBeanPlus.service.ProductCacheManager;
import cn.enjoy.design.behavior.strategy.springInitializingBeanPlus.service.SeckillOrderManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author K
 * @date 2022-11-21 21:33
 */
@RestController
@RequestMapping("strategy")
public class StrategyController {

    @Resource
    private HandlerFactory<Integer, ProductCacheManager> productCacheFactory;
    @Resource
    private HandlerFactory<String, SeckillOrderManager> seckillOrderFactory;


    @GetMapping("get")
    public void get() {
        ProductCacheManager productCache = (ProductCacheManager) productCacheFactory.getStrategy(3);
        productCache.create();

        SeckillOrderManager seckillOrder = (SeckillOrderManager) seckillOrderFactory.getStrategy("1");
        seckillOrder.getQualification();

        System.out.println();
    }

}
